package com.hmall.Item.mq;


import com.hmall.Item.constants.MqConstants;
import com.hmall.Item.service.SearchService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;

public class SearchListener {
    @Autowired
    private SearchService searchService;



    /**
     * 监听新增或修改的业务
     * @param id 酒店id
     */
    @RabbitListener(queues = MqConstants.ITEM_INSERT_QUEUE)
    public void listenHotelInsertOrUpdate(Long id){
        searchService.insertById(id);
    }

    /**
     * 监听删除的业务
     * @param id
     */
    @RabbitListener(queues = MqConstants.ITEM_DELETE_QUEUE)
    public void listenHotelDelete(Long id){
        searchService.deleteById(id);
    }
}
